# 练习1：定义一个类描述数字时钟。

from time import sleep

import time
class Clock:
    def __init__(self, hour = 0, min = 0, sec = 0):
        self.hour = hour
        self.min = min
        self.sec = sec

    # 时钟转动
    def tick(self):
            sec = self.sec + 1
            if sec > 59:
                self.sec = 0
                min = self.min + 1
                if min > 59:
                    self.min = 0
                    hour = self.hour + 1
                    if hour > 23:
                        self.hour = 0
                    else:
                        self.hour = hour
                else:
                    self.min = min
            else:
                self.sec = sec

    def get_time(self):
        print('%02d:%02d:%02d' % (self.hour, self.min, self.sec))            

                

if __name__ == '__main__':
    clock = Clock(23,59,58)
    while True:
        time.sleep(1)
        clock.tick()
        clock.get_time()

